package top.dreamix.njitkit.worker

import android.content.Context
import androidx.work.CoroutineWorker
import androidx.work.Worker
import androidx.work.WorkerParameters
import kotlinx.coroutines.flow.first
import top.dreamix.njitkit.data.yiban.AccountRepository
import top.dreamix.njitkit.service.Yiban

class YibanAutoSignInWorker(context: Context, workerParams: WorkerParameters): CoroutineWorker(context, workerParams) {
    override suspend fun doWork(): Result {
        val repository = AccountRepository(applicationContext)
        val accounts = repository.accountsFlow.first()
        accounts.forEach { account ->
            val cookies = Yiban.SchoolBased.auth(account.access_token)
//            val task = Yiban.SchoolBased.getNightAttendanceTask()
        }
        return Result.success()
    }
}